import { toLogin } from '@/api/login.js'
import { info } from '@/api/layout.js'
const state = {
  token: '',
  userInfo: ''
}
const mutations = {
  setToken (state, value) {
    state.token = value
  },
  logOut (state) {
    state.token = ''
  },
  setUserInfo (state, val) {
    state.userInfo = val
  }
}
const actions = {
  async toLogining ({ commit }, value) {
    const res = await toLogin(value)
    commit('setToken', res.data.data.token)
  },
  async toUserInfo ({ commit }, value) {
    const res = await info()
    commit('setUserInfo', res.data.data)
  }
}
const getters = {}
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
